#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
#include<vector>

using namespace std;

string multiply(string num1, string num2) {
    int len1 = num1.size(), len2 = num2.size();
    vector<int> nums(len1 + len2, 0);

    reverse(num1.begin(), num1.end());
    reverse(num2.begin(), num2.end());

    int i = 0, j = 0, ct = 0, x = 0, y = 0;
    for (int i = 0; i < len1; i++) {
        for (int j = 0; j < len2; j++) {
            x = num1[i] - '0', y = num2[j] - '0';
            nums[j + ct] += x * y;
        }
        ct++;
    }

    int plus = 0;
    string ret;
    for (int i = 0; i < nums.size(); i++) {
        nums[i] += plus;
        plus = nums[i] / 10;
        nums[i] %= 10;
    }
    int k = nums.size() - 1;
    while (k >= 0 && nums[k] == 0) {
        k--;
    }
    if (k < 0) {
        return string(1, '0');
    }
    for (; k >= 0; k--) {
        ret += nums[k] + '0';
    }

    return ret;
}

int main() {
    string num1 = "123", num2 = "456";
    cout << multiply(num1, num2) << endl;
    return 0;
}